<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="COMM">/**
<span class='line'>  2</span>  * Constructs a new, empty treemap layout. Layouts are not typically
<span class='line'>  3</span>  * constructed directly; instead, they are added to an existing panel via
<span class='line'>  4</span>  * {@link pv.Mark#add}.
<span class='line'>  5</span>  *
<span class='line'>  6</span>  * @class Implements a space-filling rectangular layout, with the hierarchy
<span class='line'>  7</span>  * represented via containment. Treemaps represent nodes as boxes, with child
<span class='line'>  8</span>  * nodes placed within parent boxes. The size of each box is proportional to the
<span class='line'>  9</span>  * size of the node in the tree. This particular algorithm is taken from Bruls,
<span class='line'> 10</span>  * D.M., C. Huizing, and J.J. van Wijk, &lt;a
<span class='line'> 11</span>  * href="http://www.win.tue.nl/~vanwijk/stm.pdf">"Squarified Treemaps"&lt;/a> in
<span class='line'> 12</span>  * &lt;i>Data Visualization 2000, Proceedings of the Joint Eurographics and IEEE
<span class='line'> 13</span>  * TCVG Sumposium on Visualization&lt;/i>, 2000, pp. 33-42.
<span class='line'> 14</span>  *
<span class='line'> 15</span>  * &lt;p>The meaning of the exported mark prototypes changes slightly in the
<span class='line'> 16</span>  * space-filling implementation:&lt;ul>
<span class='line'> 17</span>  *
<span class='line'> 18</span>  * &lt;li>&lt;tt>node&lt;/tt> - for rendering nodes; typically a {@link pv.Bar}. The node
<span class='line'> 19</span>  * data is populated with &lt;tt>dx&lt;/tt> and &lt;tt>dy&lt;/tt> attributes, in addition to
<span class='line'> 20</span>  * the standard &lt;tt>x&lt;/tt> and &lt;tt>y&lt;/tt> position attributes.
<span class='line'> 21</span>  *
<span class='line'> 22</span>  * &lt;p>&lt;li>&lt;tt>leaf&lt;/tt> - for rendering leaf nodes only, with no fill or stroke
<span class='line'> 23</span>  * style by default; typically a {@link pv.Panel} or another layout!
<span class='line'> 24</span>  *
<span class='line'> 25</span>  * &lt;p>&lt;li>&lt;tt>link&lt;/tt> - unsupported; undefined. Links are encoded implicitly
<span class='line'> 26</span>  * in the arrangement of the space-filling nodes.
<span class='line'> 27</span>  *
<span class='line'> 28</span>  * &lt;p>&lt;li>&lt;tt>label&lt;/tt> - for rendering node labels; typically a
<span class='line'> 29</span>  * {@link pv.Label}.
<span class='line'> 30</span>  *
<span class='line'> 31</span>  * &lt;/ul>For more details on how to use this layout, see
<span class='line'> 32</span>  * {@link pv.Layout.Hierarchy}.
<span class='line'> 33</span>  *
<span class='line'> 34</span>  * @extends pv.Layout.Hierarchy
<span class='line'> 35</span>  */</span><span class="WHIT">
<span class='line'> 36</span> </span><span class="NAME">pv.Layout.Treemap</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 37</span> </span><span class="WHIT">  </span><span class="NAME">pv.Layout.Hierarchy.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 38</span> 
<span class='line'> 39</span> </span><span class="WHIT">  </span><span class="NAME">this.node</span><span class="WHIT">
<span class='line'> 40</span> </span><span class="WHIT">      </span><span class="PUNC">.</span><span class="NAME">strokeStyle</span><span class="PUNC">(</span><span class="STRN">"#fff"</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 41</span> </span><span class="WHIT">      </span><span class="PUNC">.</span><span class="NAME">fillStyle</span><span class="PUNC">(</span><span class="STRN">"rgba(31, 119, 180, .25)"</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 42</span> </span><span class="WHIT">      </span><span class="PUNC">.</span><span class="NAME">width</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">n.dx</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 43</span> </span><span class="WHIT">      </span><span class="PUNC">.</span><span class="NAME">height</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">n.dy</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 44</span> 
<span class='line'> 45</span> </span><span class="WHIT">  </span><span class="NAME">this.label</span><span class="WHIT">
<span class='line'> 46</span> </span><span class="WHIT">      </span><span class="PUNC">.</span><span class="NAME">visible</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">n.firstChild</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 47</span> </span><span class="WHIT">      </span><span class="PUNC">.</span><span class="NAME">left</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">n.x</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">n.dx</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 48</span> </span><span class="WHIT">      </span><span class="PUNC">.</span><span class="NAME">top</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">n.y</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">n.dy</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 49</span> </span><span class="WHIT">      </span><span class="PUNC">.</span><span class="NAME">textAlign</span><span class="PUNC">(</span><span class="STRN">"center"</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 50</span> </span><span class="WHIT">      </span><span class="PUNC">.</span><span class="NAME">textAngle</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">n.dx</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NAME">n.dy</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NAME">Math.PI</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 51</span> 
<span class='line'> 52</span> </span><span class="WHIT">  </span><span class="PUNC">(</span><span class="NAME">this.leaf</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">pv.Mark</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 53</span> </span><span class="WHIT">      </span><span class="PUNC">.</span><span class="NAME">extend</span><span class="PUNC">(</span><span class="NAME">this.node</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 54</span> </span><span class="WHIT">      </span><span class="PUNC">.</span><span class="NAME">fillStyle</span><span class="PUNC">(</span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 55</span> </span><span class="WHIT">      </span><span class="PUNC">.</span><span class="NAME">strokeStyle</span><span class="PUNC">(</span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 56</span> </span><span class="WHIT">      </span><span class="PUNC">.</span><span class="NAME">visible</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">n.firstChild</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">parent</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 57</span> 
<span class='line'> 58</span> </span><span class="WHIT">  </span><span class="COMM">/* Hide unsupported link. */</span><span class="WHIT">
<span class='line'> 59</span> </span><span class="WHIT">  </span><span class="KEYW">delete</span><span class="WHIT"> </span><span class="NAME">this.link</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 60</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 61</span> 
<span class='line'> 62</span> </span><span class="NAME">pv.Layout.Treemap.prototype</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pv.extend</span><span class="PUNC">(</span><span class="NAME">pv.Layout.Hierarchy</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 63</span> </span><span class="WHIT">    </span><span class="PUNC">.</span><span class="NAME">property</span><span class="PUNC">(</span><span class="STRN">"round"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">Boolean</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 64</span> </span><span class="WHIT">    </span><span class="PUNC">.</span><span class="NAME">property</span><span class="PUNC">(</span><span class="STRN">"paddingLeft"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">Number</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 65</span> </span><span class="WHIT">    </span><span class="PUNC">.</span><span class="NAME">property</span><span class="PUNC">(</span><span class="STRN">"paddingRight"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">Number</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 66</span> </span><span class="WHIT">    </span><span class="PUNC">.</span><span class="NAME">property</span><span class="PUNC">(</span><span class="STRN">"paddingTop"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">Number</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 67</span> </span><span class="WHIT">    </span><span class="PUNC">.</span><span class="NAME">property</span><span class="PUNC">(</span><span class="STRN">"paddingBottom"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">Number</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 68</span> </span><span class="WHIT">    </span><span class="PUNC">.</span><span class="NAME">property</span><span class="PUNC">(</span><span class="STRN">"mode"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">String</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 69</span> </span><span class="WHIT">    </span><span class="PUNC">.</span><span class="NAME">property</span><span class="PUNC">(</span><span class="STRN">"order"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">String</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 70</span> 
<span class='line'> 71</span> </span><span class="COMM">/**
<span class='line'> 72</span>  * Default propertiess for treemap layouts. The default mode is "squarify" and
<span class='line'> 73</span>  * the default order is "ascending".
<span class='line'> 74</span>  *
<span class='line'> 75</span>  * @type pv.Layout.Treemap
<span class='line'> 76</span>  */</span><span class="WHIT">
<span class='line'> 77</span> </span><span class="NAME">pv.Layout.Treemap.prototype.defaults</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">pv.Layout.Treemap</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 78</span> </span><span class="WHIT">    </span><span class="PUNC">.</span><span class="NAME">extend</span><span class="PUNC">(</span><span class="NAME">pv.Layout.Hierarchy.prototype.defaults</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 79</span> </span><span class="WHIT">    </span><span class="PUNC">.</span><span class="NAME">mode</span><span class="PUNC">(</span><span class="STRN">"squarify"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="COMM">// squarify, slice-and-dice, slice, dice</span><span class="WHIT">
<span class='line'> 80</span> </span><span class="WHIT">    </span><span class="PUNC">.</span><span class="NAME">order</span><span class="PUNC">(</span><span class="STRN">"ascending"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// ascending, descending, reverse, null</span><span class="WHIT">
<span class='line'> 81</span> 
<span class='line'> 82</span> </span><span class="COMM">/**
<span class='line'> 83</span>  * Whether node sizes should be rounded to integer values. This has a similar
<span class='line'> 84</span>  * effect to setting &lt;tt>antialias(false)&lt;/tt> for node values, but allows the
<span class='line'> 85</span>  * treemap algorithm to accumulate error related to pixel rounding.
<span class='line'> 86</span>  *
<span class='line'> 87</span>  * @type boolean
<span class='line'> 88</span>  * @name pv.Layout.Treemap.prototype.round
<span class='line'> 89</span>  */</span><span class="WHIT">
<span class='line'> 90</span> 
<span class='line'> 91</span> </span><span class="COMM">/**
<span class='line'> 92</span>  * The left inset between parent add child in pixels. Defaults to 0.
<span class='line'> 93</span>  *
<span class='line'> 94</span>  * @type number
<span class='line'> 95</span>  * @name pv.Layout.Treemap.prototype.paddingLeft
<span class='line'> 96</span>  * @see #padding
<span class='line'> 97</span>  */</span><span class="WHIT">
<span class='line'> 98</span> 
<span class='line'> 99</span> </span><span class="COMM">/**
<span class='line'>100</span>  * The right inset between parent add child in pixels. Defaults to 0.
<span class='line'>101</span>  *
<span class='line'>102</span>  * @type number
<span class='line'>103</span>  * @name pv.Layout.Treemap.prototype.paddingRight
<span class='line'>104</span>  * @see #padding
<span class='line'>105</span>  */</span><span class="WHIT">
<span class='line'>106</span> 
<span class='line'>107</span> </span><span class="COMM">/**
<span class='line'>108</span>  * The top inset between parent and child in pixels. Defaults to 0.
<span class='line'>109</span>  *
<span class='line'>110</span>  * @type number
<span class='line'>111</span>  * @name pv.Layout.Treemap.prototype.paddingTop
<span class='line'>112</span>  * @see #padding
<span class='line'>113</span>  */</span><span class="WHIT">
<span class='line'>114</span> 
<span class='line'>115</span> </span><span class="COMM">/**
<span class='line'>116</span>  * The bottom inset between parent and child in pixels. Defaults to 0.
<span class='line'>117</span>  *
<span class='line'>118</span>  * @type number
<span class='line'>119</span>  * @name pv.Layout.Treemap.prototype.paddingBottom
<span class='line'>120</span>  * @see #padding
<span class='line'>121</span>  */</span><span class="WHIT">
<span class='line'>122</span> 
<span class='line'>123</span> </span><span class="COMM">/**
<span class='line'>124</span>  * The treemap algorithm. The default value is "squarify". The "slice-and-dice"
<span class='line'>125</span>  * algorithm may also be used, which alternates between horizontal and vertical
<span class='line'>126</span>  * slices for different depths. In addition, the "slice" and "dice" algorithms
<span class='line'>127</span>  * may be specified explicitly to control whether horizontal or vertical slices
<span class='line'>128</span>  * are used, which may be useful for nested treemap layouts.
<span class='line'>129</span>  *
<span class='line'>130</span>  * @type string
<span class='line'>131</span>  * @name pv.Layout.Treemap.prototype.mode
<span class='line'>132</span>  * @see &lt;a
<span class='line'>133</span>  * href="ftp://ftp.cs.umd.edu/pub/hcil/Reports-Abstracts-Bibliography/2001-06html/2001-06.pdf"
<span class='line'>134</span>  * >"Ordered Treemap Layouts"&lt;/a> by B. Shneiderman &amp; M. Wattenberg, IEEE
<span class='line'>135</span>  * InfoVis 2001.
<span class='line'>136</span>  */</span><span class="WHIT">
<span class='line'>137</span> 
<span class='line'>138</span> </span><span class="COMM">/**
<span class='line'>139</span>  * The sibling node order. A &lt;tt>null&lt;/tt> value means to use the sibling order
<span class='line'>140</span>  * specified by the nodes property as-is; "reverse" will reverse the given
<span class='line'>141</span>  * order. The default value "ascending" will sort siblings in ascending order of
<span class='line'>142</span>  * size, while "descending" will do the reverse. For sorting based on data
<span class='line'>143</span>  * attributes other than size, use the default &lt;tt>null&lt;/tt> for the order
<span class='line'>144</span>  * property, and sort the nodes beforehand using the {@link pv.Dom} operator.
<span class='line'>145</span>  *
<span class='line'>146</span>  * @type string
<span class='line'>147</span>  * @name pv.Layout.Treemap.prototype.order
<span class='line'>148</span>  */</span><span class="WHIT">
<span class='line'>149</span> 
<span class='line'>150</span> </span><span class="COMM">/**
<span class='line'>151</span>  * Alias for setting the left, right, top and bottom padding properties
<span class='line'>152</span>  * simultaneously.
<span class='line'>153</span>  *
<span class='line'>154</span>  * @see #paddingLeft
<span class='line'>155</span>  * @see #paddingRight
<span class='line'>156</span>  * @see #paddingTop
<span class='line'>157</span>  * @see #paddingBottom
<span class='line'>158</span>  * @returns {pv.Layout.Treemap} this.
<span class='line'>159</span>  */</span><span class="WHIT">
<span class='line'>160</span> </span><span class="NAME">pv.Layout.Treemap.prototype.padding</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>161</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.paddingLeft</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">paddingRight</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">paddingTop</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">paddingBottom</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>162</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>163</span> 
<span class='line'>164</span> </span><span class="COMM">/** @private The default size function. */</span><span class="WHIT">
<span class='line'>165</span> </span><span class="NAME">pv.Layout.Treemap.prototype.$size</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">d</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>166</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">Number</span><span class="PUNC">(</span><span class="NAME">d.nodeValue</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>167</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>168</span> 
<span class='line'>169</span> </span><span class="COMM">/**
<span class='line'>170</span>  * Specifies the sizing function. By default, the size function uses the
<span class='line'>171</span>  * &lt;tt>nodeValue&lt;/tt> attribute of nodes as a numeric value: &lt;tt>function(d)
<span class='line'>172</span>  * Number(d.nodeValue)&lt;/tt>.
<span class='line'>173</span>  *
<span class='line'>174</span>  * &lt;p>The sizing function is invoked for each leaf node in the tree, per the
<span class='line'>175</span>  * &lt;tt>nodes&lt;/tt> property. For example, if the tree data structure represents a
<span class='line'>176</span>  * file system, with files as leaf nodes, and each file has a &lt;tt>bytes&lt;/tt>
<span class='line'>177</span>  * attribute, you can specify a size function as:
<span class='line'>178</span>  *
<span class='line'>179</span>  * &lt;pre>    .size(function(d) d.bytes)&lt;/pre>
<span class='line'>180</span>  *
<span class='line'>181</span>  * @param {function} f the new sizing function.
<span class='line'>182</span>  * @returns {pv.Layout.Treemap} this.
<span class='line'>183</span>  */</span><span class="WHIT">
<span class='line'>184</span> </span><span class="NAME">pv.Layout.Treemap.prototype.size</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">f</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>185</span> </span><span class="WHIT">  </span><span class="NAME">this.$size</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pv.functor</span><span class="PUNC">(</span><span class="NAME">f</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>186</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>187</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>188</span> 
<span class='line'>189</span> </span><span class="COMM">/** @private */</span><span class="WHIT">
<span class='line'>190</span> </span><span class="NAME">pv.Layout.Treemap.prototype.buildImplied</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>191</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pv.Layout.Hierarchy.prototype.buildImplied.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>192</span> 
<span class='line'>193</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">that</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>194</span> </span><span class="WHIT">      </span><span class="NAME">nodes</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.nodes</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>195</span> </span><span class="WHIT">      </span><span class="NAME">root</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">nodes</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>196</span> </span><span class="WHIT">      </span><span class="NAME">stack</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pv.Mark.stack</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>197</span> </span><span class="WHIT">      </span><span class="NAME">left</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.paddingLeft</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>198</span> </span><span class="WHIT">      </span><span class="NAME">right</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.paddingRight</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>199</span> </span><span class="WHIT">      </span><span class="NAME">top</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.paddingTop</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>200</span> </span><span class="WHIT">      </span><span class="NAME">bottom</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.paddingBottom</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>201</span> </span><span class="WHIT">      </span><span class="COMM">/** @ignore */</span><span class="WHIT"> </span><span class="NAME">size</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">n.size</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>202</span> </span><span class="WHIT">      </span><span class="NAME">round</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.round</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">Math.round</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">Number</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>203</span> </span><span class="WHIT">      </span><span class="NAME">mode</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.mode</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>204</span> 
<span class='line'>205</span> </span><span class="WHIT">  </span><span class="COMM">/** @private */</span><span class="WHIT">
<span class='line'>206</span> </span><span class="WHIT">  </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">slice</span><span class="PUNC">(</span><span class="NAME">row</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sum</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">horizontal</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">w</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">h</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>207</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">d</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">row.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>208</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">n</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">row</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>209</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">horizontal</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>210</span> </span><span class="WHIT">        </span><span class="NAME">n.x</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">d</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>211</span> </span><span class="WHIT">        </span><span class="NAME">n.y</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">y</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>212</span> </span><span class="WHIT">        </span><span class="NAME">d</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">n.dx</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">round</span><span class="PUNC">(</span><span class="NAME">w</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">n.size</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NAME">sum</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>213</span> </span><span class="WHIT">        </span><span class="NAME">n.dy</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">h</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>214</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>215</span> </span><span class="WHIT">        </span><span class="NAME">n.x</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>216</span> </span><span class="WHIT">        </span><span class="NAME">n.y</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">y</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">d</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>217</span> </span><span class="WHIT">        </span><span class="NAME">n.dx</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">w</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>218</span> </span><span class="WHIT">        </span><span class="NAME">d</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">n.dy</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">round</span><span class="PUNC">(</span><span class="NAME">h</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">n.size</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NAME">sum</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>219</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>220</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>221</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="COMM">// correct on-axis rounding error</span><span class="WHIT">
<span class='line'>222</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">horizontal</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>223</span> </span><span class="WHIT">        </span><span class="NAME">n.dx</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">w</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">d</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>224</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>225</span> </span><span class="WHIT">        </span><span class="NAME">n.dy</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">h</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">d</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>226</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>227</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>228</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>229</span> 
<span class='line'>230</span> </span><span class="WHIT">  </span><span class="COMM">/** @private */</span><span class="WHIT">
<span class='line'>231</span> </span><span class="WHIT">  </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">ratio</span><span class="PUNC">(</span><span class="NAME">row</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">l</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>232</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">rmax</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NAME">Infinity</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">rmin</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Infinity</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>233</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">row.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>234</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">r</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">row</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">size</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>235</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">r</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">rmin</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">rmin</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">r</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>236</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">r</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NAME">rmax</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">rmax</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">r</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>237</span> </span><span class="WHIT">      </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">r</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>238</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>239</span> </span><span class="WHIT">    </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>240</span> </span><span class="WHIT">    </span><span class="NAME">l</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">l</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">l</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>241</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">Math.max</span><span class="PUNC">(</span><span class="NAME">l</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">rmax</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">l</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">rmin</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>242</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>243</span> 
<span class='line'>244</span> </span><span class="WHIT">  </span><span class="COMM">/** @private */</span><span class="WHIT">
<span class='line'>245</span> </span><span class="WHIT">  </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">layout</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>246</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">n.x</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">left</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>247</span> </span><span class="WHIT">        </span><span class="NAME">y</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">n.y</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">top</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>248</span> </span><span class="WHIT">        </span><span class="NAME">w</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">n.dx</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">left</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">right</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>249</span> </span><span class="WHIT">        </span><span class="NAME">h</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">n.dy</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">top</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">bottom</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>250</span> 
<span class='line'>251</span> </span><span class="WHIT">    </span><span class="COMM">/* Assume squarify by default. */</span><span class="WHIT">
<span class='line'>252</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">mode</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">"squarify"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>253</span> </span><span class="WHIT">      </span><span class="NAME">slice</span><span class="PUNC">(</span><span class="NAME">n.childNodes</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">n.size</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>254</span> </span><span class="WHIT">          </span><span class="NAME">mode</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"slice"</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="WHIT">
<span class='line'>255</span> </span><span class="WHIT">          </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">mode</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"dice"</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="WHIT">
<span class='line'>256</span> </span><span class="WHIT">          </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">w</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">h</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>257</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>258</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>259</span> 
<span class='line'>260</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">row</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>261</span> </span><span class="WHIT">        </span><span class="NAME">mink</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Infinity</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>262</span> </span><span class="WHIT">        </span><span class="NAME">l</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Math.min</span><span class="PUNC">(</span><span class="NAME">w</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">h</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>263</span> </span><span class="WHIT">        </span><span class="NAME">k</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">w</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">h</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NAME">n.size</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>264</span> 
<span class='line'>265</span> </span><span class="WHIT">    </span><span class="COMM">/* Abort if the size is nonpositive. */</span><span class="WHIT">
<span class='line'>266</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">n.size</span><span class="WHIT"> </span><span class="PUNC">&lt;=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>267</span> 
<span class='line'>268</span> </span><span class="WHIT">    </span><span class="COMM">/* Scale the sizes to fill the current subregion. */</span><span class="WHIT">
<span class='line'>269</span> </span><span class="WHIT">    </span><span class="NAME">n.visitBefore</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">n.size</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>270</span> 
<span class='line'>271</span> </span><span class="WHIT">    </span><span class="COMM">/** @private Position the specified nodes along one dimension. */</span><span class="WHIT">
<span class='line'>272</span> </span><span class="WHIT">    </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">position</span><span class="PUNC">(</span><span class="NAME">row</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>273</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">horizontal</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">w</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">l</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>274</span> </span><span class="WHIT">          </span><span class="NAME">sum</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pv.sum</span><span class="PUNC">(</span><span class="NAME">row</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">size</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>275</span> </span><span class="WHIT">          </span><span class="NAME">r</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">l</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">round</span><span class="PUNC">(</span><span class="NAME">sum</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NAME">l</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>276</span> </span><span class="WHIT">      </span><span class="NAME">slice</span><span class="PUNC">(</span><span class="NAME">row</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sum</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">horizontal</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">horizontal</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">w</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">r</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">horizontal</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">r</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">h</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>277</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">horizontal</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>278</span> </span><span class="WHIT">        </span><span class="NAME">y</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">r</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>279</span> </span><span class="WHIT">        </span><span class="NAME">h</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">r</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>280</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>281</span> </span><span class="WHIT">        </span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">r</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>282</span> </span><span class="WHIT">        </span><span class="NAME">w</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">r</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>283</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>284</span> </span><span class="WHIT">      </span><span class="NAME">l</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Math.min</span><span class="PUNC">(</span><span class="NAME">w</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">h</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>285</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">horizontal</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>286</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>287</span> 
<span class='line'>288</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">children</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">n.childNodes.slice</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// copy</span><span class="WHIT">
<span class='line'>289</span> </span><span class="WHIT">    </span><span class="KEYW">while</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">children.length</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>290</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">child</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">children</span><span class="PUNC">[</span><span class="NAME">children.length</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>291</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">child.size</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>292</span> </span><span class="WHIT">        </span><span class="NAME">children.pop</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>293</span> </span><span class="WHIT">        </span><span class="KEYW">continue</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>294</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>295</span> </span><span class="WHIT">      </span><span class="NAME">row.push</span><span class="PUNC">(</span><span class="NAME">child</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>296</span> 
<span class='line'>297</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">k</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">ratio</span><span class="PUNC">(</span><span class="NAME">row</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">l</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>298</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">k</span><span class="WHIT"> </span><span class="PUNC">&lt;=</span><span class="WHIT"> </span><span class="NAME">mink</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>299</span> </span><span class="WHIT">        </span><span class="NAME">children.pop</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>300</span> </span><span class="WHIT">        </span><span class="NAME">mink</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>301</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>302</span> </span><span class="WHIT">        </span><span class="NAME">row.pop</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>303</span> </span><span class="WHIT">        </span><span class="NAME">position</span><span class="PUNC">(</span><span class="NAME">row</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>304</span> </span><span class="WHIT">        </span><span class="NAME">row.length</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>305</span> </span><span class="WHIT">        </span><span class="NAME">mink</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Infinity</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>306</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>307</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>308</span> 
<span class='line'>309</span> </span><span class="WHIT">    </span><span class="COMM">/* correct off-axis rounding error */</span><span class="WHIT">
<span class='line'>310</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">position</span><span class="PUNC">(</span><span class="NAME">row</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">row.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>311</span> </span><span class="WHIT">      </span><span class="NAME">row</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">dy</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">h</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>312</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">row.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>313</span> </span><span class="WHIT">      </span><span class="NAME">row</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">dx</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">w</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>314</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>315</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>316</span> 
<span class='line'>317</span> </span><span class="WHIT">  </span><span class="COMM">/* Recursively compute the node depth and size. */</span><span class="WHIT">
<span class='line'>318</span> </span><span class="WHIT">  </span><span class="NAME">stack.unshift</span><span class="PUNC">(</span><span class="KEYW">null</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>319</span> </span><span class="WHIT">  </span><span class="NAME">root.visitAfter</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>320</span> </span><span class="WHIT">      </span><span class="NAME">n.depth</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>321</span> </span><span class="WHIT">      </span><span class="NAME">n.x</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">n.y</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">n.dx</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">n.dy</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>322</span> </span><span class="WHIT">      </span><span class="NAME">n.size</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">n.firstChild</span><span class="WHIT">
<span class='line'>323</span> </span><span class="WHIT">          </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">pv.sum</span><span class="PUNC">(</span><span class="NAME">n.childNodes</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">n.size</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>324</span> </span><span class="WHIT">          </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">that.$size.apply</span><span class="PUNC">(</span><span class="NAME">that</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">stack</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">n</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">stack</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>325</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>326</span> </span><span class="WHIT">  </span><span class="NAME">stack.shift</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>327</span> 
<span class='line'>328</span> </span><span class="WHIT">  </span><span class="COMM">/* Sort. */</span><span class="WHIT">
<span class='line'>329</span> </span><span class="WHIT">  </span><span class="KEYW">switch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s.order</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>330</span> </span><span class="WHIT">    </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">"ascending"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>331</span> </span><span class="WHIT">      </span><span class="NAME">root.sort</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">b</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">a.size</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">b.size</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>332</span> </span><span class="WHIT">      </span><span class="KEYW">break</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>333</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>334</span> </span><span class="WHIT">    </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">"descending"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>335</span> </span><span class="WHIT">      </span><span class="NAME">root.sort</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">b</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">b.size</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">a.size</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>336</span> </span><span class="WHIT">      </span><span class="KEYW">break</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>337</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>338</span> </span><span class="WHIT">    </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">"reverse"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">root.reverse</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="KEYW">break</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>339</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>340</span> 
<span class='line'>341</span> </span><span class="WHIT">  </span><span class="COMM">/* Recursively compute the layout. */</span><span class="WHIT">
<span class='line'>342</span> </span><span class="WHIT">  </span><span class="NAME">root.x</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>343</span> </span><span class="WHIT">  </span><span class="NAME">root.y</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>344</span> </span><span class="WHIT">  </span><span class="NAME">root.dx</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.width</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>345</span> </span><span class="WHIT">  </span><span class="NAME">root.dy</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.height</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>346</span> </span><span class="WHIT">  </span><span class="NAME">root.visitBefore</span><span class="PUNC">(</span><span class="NAME">layout</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>347</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>348</span> </span></pre></body></html>